<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>布局管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/systemStatic/style/admin.css">
    <link rel="stylesheet" href="${ctx}/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/css/public.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
</head>
<body>
    <div style="padding: 10px;">
        <table id="laymanListTable" lay-filter="laymanListTable"></table>
    </div>
    <!-- 头部工具栏 -->
    <script type="text/html" id="laymanHeaderToolsBar">
        <div class="ccpui-enterSel">
            <div class="layui-btn-container">
                <a href="${ctx}/system/indexLayoutManage/view/edit" class="layui-btn layui-btn-sm">
                    <i class="layui-icon layui-icon-add-1"></i>
                    <span>新增</span>
                </a>
                <a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="delete">
                    <i class="layui-icon layui-icon-delete"></i>
                    <span>删除</span>
                </a>
                <a class="layui-btn layui-btn-sm" lay-event="query">
                    <i class="layui-icon layui-icon-search"></i>
                    <span>查询</span>
                </a>
                <a class="layui-btn layui-btn-sm" lay-event="clears">
                    <i class="layui-icon layui-icon-refresh-3"></i>
                    <span>重置</span>
                </a>
            </div>
            <form class="layui-form" action="" lay-filter="layoutListLayoutManageSelect" style="margin-top:10px">
                <div class="table-top-filter">
                    <div class="table-filter-alone">
                        <label class="layui-form-label">布局名称</label>
                        <input type="text" class="layui-input  filter-value" name="Q_name_SL" placeholder="布局名称"/>
                    </div>
                    <div class="table-filter-alone">
                        <label class="layui-form-label">布局描述</label>
                        <input type="text" class="layui-input  filter-value" name="Q_memo_SL" placeholder="布局描述"/>
                    </div>
                    <div class="table-filter-alone">
                        <label class="layui-form-label">所属组织</label>
                        <input type="text" class="layui-input  filter-value" name="Q_orgName_SL" placeholder="所属组织"/>
                    </div>
                    <div class="table-filter-alone">
                        <label class="layui-form-label">是否默认</label>
                        <select class="filter-value" name="isDef">
                            <option value="">-----请选择----</option>
                            <option value="1">是</option>
                            <option value="0">否</option>
                        </select>
                    </div>
                </div>
            </form>
        </div>
    </script>
    <!-- 右侧工具栏 -->
    <script type="text/html" id="laymanRightToolsBar">
            <a class="layui-btn layui-btn-xs" lay-event="preview">预览</a>
            <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
            <a class="layui-btn layui-btn-xs" lay-event="apply">应用</a>
    </script>
    <script src="${ctx}/public/component.js" type="text/javascript"></script>
    <script src="${ctx}/layui/layui.js"></script>
    <script>

        layui.config({
            base: serverPath.systemPath + staticPath.systemPath //静态资源所在路径
        }).extend({
            index: 'index' //主入口模块
        }).use(['index','table','layer','setter','common','commons','totalFilter'], function () {
            var table = layui.table,setter=layui.setter,common = layui.common,$=layui.jquery,commons=layui.commons,layer = layui.layer,totalFilter=layui.totalFilter;
            var tableHeight=commons.tabHeight();
            console.log(screen.height)
            if(screen.height*1<=768){
                tableHeight='full-60';
            };
            window.onresize = function(){
                if(screen.height*1<=768){
                    $(".layui-table-main").css("height",$(".layui-table-main").outerHeight()+50+'px')
                }
            }
            //第一个实例
            table.render({
                elem: '#laymanListTable',
                title: '首页栏目信息列表',
                url: serverPath.systemPath + setter.sysLinkPath+ 'indexLayoutManage/list', //数据接口
                page: true, //开启分页
                method: 'get',
                autoSort: true,//禁用前端排序
                defaultToolbar: ['filter', 'print'],
                height: tableHeight,
                toolbar: '#laymanHeaderToolsBar',
                cols: [
                    [ //表头
                        {
                            type: 'checkbox',
                            fixed: 'left'
                        },
                        {
                            field: 'id',
                            title: '主键',
                            hide: true
                        },
                        {
                            field: 'name',
                            title: '布局名称',
                            sort: true
                        },
                        {
                            field: 'memo',
                            title: '布局描述',
                            sort: true
                        },
                        {
                            field: 'orgName',
                            title: '所属组织',
                            sort: true
                        },
                        {
                            field: 'isDef',
                            title: '是否默认',
                            sort: true,
                            templet: function(d) {
                                if (d.isDef == 0) {
                                    return '否';
                                }
                                return '是';
                            }
                        },
                        {
                            fixed: 'right',
                            align: 'center',
                            title: '管理',
                            toolbar: '#laymanRightToolsBar'
                        }
                    ]
                ],done:function () {
                    common.tableSelectCon('.ccpui-enterSel .layui-form input','a[lay-event=query]','.ccpui-enterSel');
                }
            });
            totalFilter.init('laymanListTable');
            //监听头工具栏事件
            table.on('toolbar(laymanListTable)', function (obj) {
                var checkStatus = table.checkStatus(obj.config.id);
                var data = checkStatus.data;
                switch (obj.event) {
                    case 'delete':
                        if (data.length === 0) {
                            layer.msg('请先选择一行数据！');
                        } else {
                            var seleIds = [];
                            for (var i = 0; i < data.length; i++) {
                                seleIds.push(data[i].id);
                            }
                            $.ajax({
                                url: serverPath.systemPath + setter.sysLinkPath + "indexLayoutManage/del",
                                type: "POST",
                                dataType: 'json',
                                data:{ids:seleIds.join(",")},
                                success: function (data) {
                                    if (commons._filterRecord(data)) {
                                        layer.alert(data.msg);
                                        table.reload('laymanListTable', {
                                            page: {curr: 1, limit: 10}
                                        });
                                        totalFilter.init('laymanListTable');
                                    } else {
                                        layer.alert(data.msg);
                                    }
                                }
                            })
                        }
                        break;
                    case 'query':
                        common.tableConditionRender("laymanListTable","layoutListLayoutManageSelect",{where:{}},false);
                        break;
                    case 'clears':
                        common.tableConditionRender("laymanListTable","layoutListLayoutManageSelect",{where:{}},true);
                        break;
                }
            });

            //监听行工具事件
            table.on('tool(laymanListTable)', function (obj) {
                var data = obj.data;//获得当前行数据
                switch (obj.event) {
                    case 'preview':
                        window.open(serverPath.systemPath  + setter.sysLinkPath+'indexLayoutManage/view/view?id=' + data.id );
                        break;
                    case 'del':
                        layer.confirm('确定删除当前数据吗？', function (index) {
                            layer.close(index);
                            $.ajax({
                                url: serverPath.systemPath + setter.sysLinkPath + "indexLayoutManage/del",
                                type: "POST",
                                dataType: 'json',
                                data:{ids:data.id},
                                success: function (data) {
                                    if (commons._filterRecord(data)) {
                                        layer.alert(data.msg);
                                        table.reload('laymanListTable', {
                                            page: {curr: 1, limit: 10}
                                        });
                                        totalFilter.init('laymanListTable');
                                    } else {
                                        layer.alert(data.msg);
                                    }
                                }
                            })
                        });
                        break;
                    case 'edit':
                        $(this).attr("href", serverPath.systemPath+setter.sysLinkPath+"indexLayoutManage/view/edit?id=" +data.id);
                        break;
                    case 'apply':
                        layer.confirm('确定应用当前布局为默认布局吗？', function (index) {
                            $.ajax({
                                url: serverPath.systemPath + setter.sysLinkPath + "indexLayoutManage/apply",
                                type: "POST",
                                dataType: 'json',
                                data:{id:data.id},
                                success: function (data) {
                                    layer.alert(data.msg);
                                    common.tableConditionRender("laymanListTable","layoutListLayoutManageSelect",{where:{}},false);
                                }
                            })

                        });
                }
            });

        });
    </script>
    </body>
    </html>
<link rel="stylesheet" href="${ctx}/css/font/iconfontie.css" media="all"/>
<link rel="stylesheet" href="${ctx}/iconfont/iconfont.css"/>